home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Compute! Gazette 1990 June
/
1990-06.d64
/
bas_beg 3
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-09-20
|
1KB
|
27 lines
5 print"[147]":poke53280,6:poke53281,6
10 for j=54272 to 54295:poke j,0:next:rem clear sound chip
20 poke 54275,8:poke 54296,15:rem square wave, full volume, no adsr for tick
30 poke 54273,100:rem set tick pitch. try others
40 input "[147]hours";t(1):if t(1)>12 then 40
50 input "minutes";t(2):if t(2)>59 then print"[145][145][145]":goto 50
60 input "seconds";t(3):if t(3)>59 then print"[145][145][145]":goto 60
99 rem line 100 calculates pokeable values for 3 time-of-day memory registers
100 for i=1 to 3:h=int(t(i)/10):l=t(i)-10*h:t(i)=16*h+l:next
110 c=56331:rem top of 4 tod registers
120 poke c,t(1):poke c-1,t(2):poke c-2,t(3):rem fills top three registers
121 rem line 120 another way: for i=0 to 3:poke c-i,t(i+1):next
130 print "press any key to start clock."
140 get a$:if a$="" then 140
150 print "[147]"
160 poke c-3,0:rem starts clock
169 rem lines 170-240 form loop which repeatedly reads the 4 memory registers
170 h=peek(c):m=peek(c-1):s=peek(c-2):t=peek(c-3):rem reading the registers
180 c1$=chr$((16 and h)/16+48)+chr$((15 and h)+48):rem forming hours string
190 c2$=chr$((240 and m)/16+48)+chr$((15 and m)+48):rem forming minutes string
200 c3$=chr$((240 and s)/16+48)+chr$((15 and s)+48):rem forming seconds string
210 if c3$=c4$ then 230:rem if not the same, print time & skip sound subroutine
220 gosub 300:c4$=c3$:rem c3$ <> c4$, therefore sound tick, make c4$=c3$ again
230 print "time is "c1$+":"+c2$+":"+c3$+":"t"[145]":rem print time, cursor up
240 goto 170
300 poke 54276,65:poke 54276,64:return:rem turns sound on and off quickly